<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js"></script>
<body>
 <script>
  var other_origin = get_host_info().UNAUTHENTICATED_ORIGIN + "wasm_streaming/resources/blank.html";
  promise_test(() => {
    return new Promise((resolve, reject) => {
      frame = document.body.appendChild(document.createElement("iframe"));
      frame.src = other_origin;
      frame.onload = () => {
        var wnd = frame.contentWindow;
        var promise = WebAssembly.compileStreaming.call(wnd);
        var objConstructor = promise.__proto__.__proto__.constructor;
        var promiseConstructor = Promise.__proto__.__proto__.constructor;
        promise.catch(e => {
          assert_true(e instanceof TypeError);
          if (objConstructor === promiseConstructor) {
            resolve();
          } else {
            reject();
          };
       });
     }
    });
  }, "wasm compileStreaming does not leak foreign contexts");

    promise_test(() => {
    return new Promise((resolve, reject) => {
      frame = document.body.appendChild(document.createElement("iframe"));
      frame.src = other_origin;
      frame.onload = () => {
        var wnd = frame.contentWindow;
        var promise = WebAssembly.instantiateStreaming.call(wnd);
        var objConstructor = promise.__proto__.__proto__.constructor;
        var promiseConstructor = Promise.__proto__.__proto__.constructor;
        promise.catch(e => {
          assert_true(e instanceof TypeError);
          if (objConstructor === promiseConstructor) {
            resolve();
          } else {
            reject();
          };
       });
     }
    });
  }, "wasm instantiateStreaming does not leak foreign contexts");

</script>
</body>
